<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover" />
    <title>奖惩审核</title>
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/weui.min.css')}}">
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/jquery-weui.css')}}">
    <link rel="stylesheet" href="{{asset('/css/system/iconfont.css')}}">
    <link rel="stylesheet" href="{{assethelp('/css/system/shenhe.css?v='.time())}}">
    @if($skinid == 3)
        <link rel="stylesheet" href="/css/system/common.css?v=2018121301">
        <link rel="stylesheet" href="/css/system/rewards-punish.css?v={{time()}}">
    @elseif($skinid == 1)
        <link rel="stylesheet" href="/css/theme-blue/system/common.css">
        <link rel="stylesheet" href="/css/theme-blue/system/rewards-punish.css?v={{time()}}">
    @elseif($skinid == 2)
        <link rel="stylesheet" href="/css/theme-pink/system/iconfont-pink.css">
        <link rel="stylesheet" href="/css/theme-pink/system/common.css?v={{time()}}">
        <link rel="stylesheet" href="/css/theme-pink/system/rewards-punish.css?v={{time()}}">
    @endif
    @include('sysadmin.head')
</head>
<body ontouchstart>
<div class="mian-container">
    <div class="rewards-punish">
        {{--<div class="weui-cells">
          <a class="weui-cell weui-cell_access" href="{{url('/sysadmin/reward/reward-punish-set')}}">
            <div class="weui-cell__bd">
              <p>奖惩设置：</p>
            </div>
            <div class="weui-cell__ft">
            </div>
          </a>        
        </div>--}}
        <div class="weui-tab">
          <div class="weui-navbar">
            <a class="weui-navbar__item weui-bar__item--on" href="#tab1">
              <i class="icon icon-a iconfont icon-xiaolian15"></i>
              <p>奖励<span style="color: red;">({{$rcount}})</span></p>
            </a>
            <a class="weui-navbar__item" href="#tab2">
              <i class="icon icon-a iconfont icon-kulian"></i>
              <p>惩罚<span style="color: red;">({{$pcount}})</span></p>
            </a>
          </div>
          <div class="weui-tab__bd">
            <div id="tab1" class="weui-tab__bd-item weui-tab__bd-item--active">
                @foreach($reward as $p)
                    @if($p->is_effective == 0)
                        <div class="rewards-section">
                            <div class="header-sec">
                                <h3>{{$p->created_at->format('Ymd')}}奖励</h3>
                                <p class="icon-level">{{$p->grade}}</p>
                            </div>
                            <div class="middle-sec">
                                <p class="text-left">{{getUserName($p->from_user_id)}}对{{getUserName($p->to_user_id)}}</p>
                                <p class="text-middle">{{$p->reason}}</p>
                                <div>
                                    <a class="link-a change-level" href="javascript:void(0);" value="{{$p->grade}}" data-values="{{$p->score}}">修改等级</a>
                                    <input type="hidden" class="level-input">
                                    <a class="link-a pass-link" data-id="{{$p->id}}" href="javascript:void(0);">通过</a>
                                    <a class="link-a refuse-link" data-id="{{$p->id}}" href="javascript:void(0);">拒绝</a>
                                </div>
                                <p class="text-list">审批流程</p>
                                <div class="hidden-list weui-cells">
                                    @foreach($p->log as $k=>$pd)
                                        <div class="weui-cell">
                                            <div class="">
                                                    @if($k != 0)
                                                        <div class="shenhe-vline-before" >
                                                            <div class="weui-cell__bd" style="">

                                                            </div>
                                                        </div>
                                                    @endif
                                                    @if($pd->method == 3)
                                                        <div class="shenhe-icon-div" ><img src="/images/shenhe/xiugai.png" ></div>
                                                    @elseif($pd->method == 2)
                                                        <div  class="shenhe-icon-div" ><img src="/images/shenhe/chahao.png" ></div>
                                                    @elseif($pd->method == 4)
                                                        <div  class="shenhe-icon-div" ><img src="/images/shenhe/wenhao.png" ></div>
                                                    @else
                                                        <i class="weui-icon-success shenhe-icon-success"></i>
                                                    @endif
                                                    @if($k != ($p->log->count()-1))
                                                        <div class="shenhe-vline-after" >
                                                            <div class="weui-cell__bd" style="">

                                                            </div>
                                                        </div>
                                                    @endif
                                            </div>
                                            <div class="weui-cell__bd shenhe-content" style="    ">
                                                <p >{{usergroup($pd->group_id)}}<span class="shenhe-content-span" >{{str_limit($pd->des,14)}}</span>
                                                    <span style="color:#ec6841; margin-left: 8px;" onclick="xianshi('{{$pd->des}}')">详情</span>
                                                    <span class="shenhe-content-span-second" >{{$pd->created_at->format('Y-m-d')}}</span>
                                                </p>
                                                <div class="shenhe-content-time-div" >
                                                    <div class="weui-cell__bd shenhe-time-content" style="text-align: right;">

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    @endforeach
                                </div>
                            </div>
                        </div>
                    @endif
                @endforeach
                @foreach($reward as $p)
                    @if($p->is_effective != 0)
                        <div class="rewards-section">
                        <div class="header-sec">
                            <h3>{{$p->created_at->format('Ymd')}}奖励</h3>
                            <p class="icon-level">{{$p->grade}}</p>
                        </div>
                        <div class="middle-sec">
                            <p class="text-left">{{getUserName($p->from_user_id)}}对{{getUserName($p->to_user_id)}}</p>
                            <p class="text-middle">{{$p->reason}}</p>
                            <p class="text-right">@if($p->is_effective == 1)已通过@elseif($p->is_effective == 2)未通过@else审核中@endif</p>
                            <p class="text-list">审批流程</p>
                            <div class="hidden-list weui-cells">
                                @foreach($p->log as $k=>$pd)
                                    <div class="weui-cell">
                                        <div class="">
                                            @if($k != 0)
                                                <div class="shenhe-vline-before" >
                                                    <div class="weui-cell__bd" style="">

                                                    </div>
                                                </div>
                                            @endif

                                                @if($pd->method == 3)
                                                    <div class="shenhe-icon-div" ><img src="/images/shenhe/xiugai.png" ></div>
                                                @elseif($pd->method == 2)
                                                    <div  class="shenhe-icon-div" ><img src="/images/shenhe/chahao.png" ></div>
                                                @elseif($pd->method == 4)
                                                    <div  class="shenhe-icon-div" ><img src="/images/shenhe/wenhao.png" ></div>
                                                @else
                                                    <i class="weui-icon-success shenhe-icon-success"></i>
                                                @endif
                                                @if($k != ($p->log->count()-1))
                                                <div class="shenhe-vline-after" >
                                                    <div class="weui-cell__bd" style="">

                                                    </div>
                                                </div>
                                                @endif
                                        </div>

                                        <div class="weui-cell__bd shenhe-content" style="    ">
                                            <p >{{usergroup($pd->group_id)}}<span class="shenhe-content-span" >{{str_limit($pd->des,14)}}</span>
                                                <span style="color:#ec6841; margin-left: 8px;" onclick="xianshi('{{$pd->des}}')">详情</span>
                                                <span class="shenhe-content-span-second" >{{$pd->created_at->format('Y-m-d')}}</span>
                                            </p>
                                            <div class="shenhe-content-time-div" >
                                                <div class="weui-cell__bd shenhe-time-content" style="text-align: right;">

                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                @endforeach
                            </div>
                        </div>
                    </div>
                    @endif
                @endforeach
            </div>
            <div id="tab2" class="weui-tab__bd-item">
                @foreach($punish as $p)
                    @if($p->is_effective == 0)
                        <div class="rewards-section">
                            <div class="header-sec">
                                <h3>{{$p->created_at->format('Ymd')}}惩罚</h3>
                                <p class="icon-level">{{$p->grade}}</p>
                            </div>
                            <div class="middle-sec">
                                <p class="text-left">{{getUserName($p->from_user_id)}}对{{getUserName($p->to_user_id)}}</p>
                                <p class="text-middle">{{$p->reason}}</p>
                                <div>
                                    <a class="link-a change-level" href="javascript:void(0);" value="{{$p->grade}}" data-values="{{$p->score}}">修改等级</a>
                                    <input type="hidden" class="level-input">
                                    <a class="link-a pass-link" data-id="{{$p->id}}" href="javascript:void(0);">通过</a>
                                    <a class="link-a refuse-link" data-id="{{$p->id}}" href="javascript:void(0);">拒绝</a>
                                </div>
                                <p class="text-list">审批流程</p>
                                <div class="hidden-list weui-cells">
                                    @foreach($p->log as $k=>$pd)
                                        <div class="weui-cell">
                                            <div class="">
                                                @if($k != 0)
                                                    <div class="shenhe-vline-before" >
                                                        <div class="weui-cell__bd" style="">

                                                        </div>
                                                    </div>
                                                @endif
                                                @if($pd->method == 3)
                                                    <div class="shenhe-icon-div" ><img src="/images/shenhe/xiugai.png" ></div>
                                                @elseif($pd->method == 2)
                                                    <div  class="shenhe-icon-div" ><img src="/images/shenhe/chahao.png" ></div>
                                                @elseif($pd->method == 4)
                                                    <div  class="shenhe-icon-div" ><img src="/images/shenhe/wenhao.png" ></div>
                                                @else
                                                    <i class="weui-icon-success shenhe-icon-success"></i>
                                                @endif
                                                @if($k != ($p->log->count()-1))
                                                    <div class="shenhe-vline-after" >
                                                        <div class="weui-cell__bd" style="">

                                                        </div>
                                                    </div>
                                                @endif
                                            </div>
                                            <div class="weui-cell__bd shenhe-content" style="    ">
                                                <p >{{usergroup($pd->group_id)}}<span class="shenhe-content-span" >{{str_limit($pd->des,14)}}</span>
                                                    <span style="color:#ec6841; margin-left: 8px;" onclick="xianshi('{{$pd->des}}')">详情</span>
                                                    <span class="shenhe-content-span-second" >{{$pd->created_at->format('Y-m-d')}}</span>
                                                </p>
                                                <div class="shenhe-content-time-div" >
                                                    <div class="weui-cell__bd shenhe-time-content" style="text-align: right;">

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    @endforeach
                                </div>
                            </div>
                        </div>
                    @endif
                @endforeach
                @foreach($punish as $p)
                    @if($p->is_effective != 0)
                        <div class="rewards-section">
                            <div class="header-sec">
                                <h3>{{$p->created_at->format('Ymd')}}惩罚</h3>
                                <p class="icon-level">{{$p->grade}}</p>
                            </div>
                            <div class="middle-sec">
                                <p class="text-left">{{getUserName($p->from_user_id)}}对{{getUserName($p->to_user_id)}}</p>
                                <p class="text-middle">{{$p->reason}}</p>
                                <p class="text-right">@if($p->is_effective == 1)已通过@elseif($p->is_effective == 2)未通过@else审核中@endif</p>
                                <p class="text-list">审批流程</p>
                                <div class="hidden-list weui-cells">
                                    @foreach($p->log as $k=>$pd)
                                        <div class="weui-cell">
                                            <div class="">
                                                @if($k != 0)
                                                    <div class="shenhe-vline-before" >
                                                        <div class="weui-cell__bd" style="">

                                                        </div>
                                                    </div>
                                                @endif
                                                @if($pd->method == 3)
                                                    <div class="shenhe-icon-div" ><img src="/images/shenhe/xiugai.png" ></div>
                                                @elseif($pd->method == 2)
                                                    <div  class="shenhe-icon-div" ><img src="/images/shenhe/chahao.png" ></div>
                                                @elseif($pd->method == 4)
                                                    <div  class="shenhe-icon-div" ><img src="/images/shenhe/wenhao.png" ></div>
                                                @else
                                                    <i class="weui-icon-success shenhe-icon-success"></i>
                                                @endif
                                                @if($k != ($p->log->count()-1))
                                                    <div class="shenhe-vline-after" >
                                                        <div class="weui-cell__bd" style="">

                                                        </div>
                                                    </div>
                                                @endif
                                            </div>
                                            <div class="weui-cell__bd shenhe-content" style="    ">
                                                <p >
                                                    {{str_limit(usergroup($pd->group_id),8)}}
                                                    <span class="shenhe-content-span" >{{str_limit($pd->des,14)}}</span>
                                                    <span style="color:#ec6841; margin-left: 8px;" onclick="xianshi('{{$pd->des}}')">详情</span>
                                                    <span class="shenhe-content-span-second" >{{$pd->created_at->format('Y-m-d')}}</span>
                                                </p>
                                                <div class="shenhe-content-time-div" >
                                                    <div class="weui-cell__bd shenhe-time-content" style="text-align: right;">

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    @endforeach
                                </div>
                            </div>
                        </div>
                    @endif
                @endforeach
            </div>
             {!! csrf_field() !!}
          </div>
        </div>
    </div>
    <!-- 隐藏考核按钮部分-->
    <div class="reful-tabbar">
        <a href="{{url('/user/performance/perf')}}" class="tabbar-item">
            <p style="line-height: 65px;" class="tabbar-label">返回个人用户界面</p>
        </a>
    </div>

    {{--隐藏部分--}}
    <div class="shadow-hidden"></div>
    <div class="hidden-sec">
        <div class="popup"><h3>填写拒绝理由</h3><i class="weui-icon-cancel"></i></div>
        <p>请填写拒绝理由</p>
        <textarea type="text" value="" name="pro-reason" class="input text-input" placeholder="选填"></textarea>

        <a class="sub-mit modi-nickname" href="javascript:void(0);">保存</a>
    </div>
</div>
<script src="{{asset('/kaohe/js/jquery-2.1.4.min.js')}}"></script>
<script src="{{asset('/addons/jquery-weui-build/js/fastclick.js')}}"></script>
<script>
    $(function() {
        document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
        FastClick.attach(document.body);
    });
</script>
<script src="{{asset('/addons/jquery-weui-build/js/jquery-weui.min.js')}}"></script>
<script>
    function xianshi(a){
        $.toast(a,"text");
    }

    $(document).ready(function () {
        $('.text-list').click(function(){
            $(this).toggleClass('text-cha');
            $(this).next('.hidden-list').toggle();
        })
        $('.kaohe-item').click(function(){
            $('.show-hidden').toggle();
        });
        $('.admin-item').click(function(){
            $('.front-show-hidden').toggle();
        });
        /*$('.change-level').click(function(){
            var that = this
            $(that).picker({
              title: "选择等级",
              cols: [
                {
                  textAlign: 'center',
                  values: [ '低级','中级', '高级']
                }
              ],
              onClose: function(data){
                  //ajax，后台
                console.log( $(that).parent().parent().parent().find('.icon-level').text());
                 
                $(that).parent().parent().parent().find('.icon-level').text(data.value[0]);
              }
            });  
        });*/


        var rearray = {!! $reward_set !!};
        $(".change-level").select({
            title: "选择等级",
            items: rearray,
            autoClose:false,
            onChange:function (da) {
                console.log(da);
            },
            onClose:function(data){
                $(data.$input).parent().parent().parent().find('p.icon-level').text(data.data.titles);
            }
        });

        var puarray = {!! $punish_set !!};
        $(".change-p-level").select({
            title: "选择等级",
            items: puarray,
            autoClose:false,
            onChange:function (da) {
                console.log(da);
            },
            onClose:function(data){
                $(data.$input).parent().parent().parent().find('p.icon-level').text(data.data.titles);
            }
        });

        $('.refuse-link').click(function(){
            $('.shadow-hidden').css('display','block');
            $('.hidden-sec').css('display','block');
            var rid = $(this).attr('data-id');
            var grade = $(this).parent().find('a.change-level').val();
            var level = $(this).parent().find('a.change-level').attr('data-values');
//            alert(grade);
//            alert(level);
            var token = $('input[name=_token]').val();
            $('.sub-mit').off('click').on('click',function(){
                var reason  = $("textarea[name='pro-reason']").val();
                if(reason.length > 30){
                    $.toast('原因太长,请减少字数','text');
                    return false;
                }
                $.ajax({
                    'url': '/sysadmin/reward/verify-reward?agree=2&_token='+token+'&rid='+rid,
                    'type': 'POST',
                    'data': '&grade='+grade+'&level='+level+'&reason='+reason,
                    error: function (request) {
                        $.toast('网络错误',"text");
                    },
                    success: function (data) {
                        if (data.status == 'success') {
                            $.toast("操作成功");
                            setTimeout(function(){ window.location.reload(); }, 1000);
                        } else {
                            $.toast(data.msg,"text");
                        }
                    },
                });
                $('.hidden-sec').css('display','none');
                $('.shadow-hidden').css('display','none');
            })
        });

        $('.hidden-sec .popup i').click(function () {
            $('.hidden-sec').css('display','none');
            $('.shadow-hidden').css('display','none');
        });

        $('.pass-link').click(function(){
            var rid = $(this).attr('data-id');
            var grade = $(this).parent().find('a.change-level').attr('value');
            var level = $(this).parent().find('a.change-level').attr('data-values');
            //alert(grade);
            //alert(level);
            var token = $('input[name=_token]').val();
            $.ajax({
                'url': '/sysadmin/reward/verify-reward?agree=1&_token='+token+'&rid='+rid,
                'type': 'POST',
                'data': '&grade='+grade+'&level='+level,
                error: function (request) {
                    $.toast('网络错误',"text");
                },
                success: function (data) {
                    if (data.status == 'success') {
                        $.toast("操作成功");
                        setTimeout(function(){ window.location.reload(); }, 1000);
                    } else {
                        $.toast(data.msg,"text");
                    }
                },
            });
        });
    })
</script>
</body>
</html>